Skip to content

fix(auto-instrumentation): Upgrade @apm-js-collab/code-transformer to v0.11.0#1708

Open
Stephen Belanger (Qard) wants to merge 6 commits intomainfrom
upgrade-orchestrion-0.11
Open

fix(auto-instrumentation): Upgrade @apm-js-collab/code-transformer to v0.11.0#1708
Stephen Belanger (Qard) wants to merge 6 commits intomainfrom
upgrade-orchestrion-0.11

Conversation

@Qard
Copy link
Copy Markdown
Contributor

Summary

  • Upgrades @apm-js-collab/code-transformer from ^0.9.0 to ^0.11.0, picking up the v0.11.0 JS rewrite (replaces the previous WASM-based transformer)
  • Fixes the ESM loader hook to pass the correct module type (esm/cjs/unknown) based on Node.js loader format, instead of always passing "unknown" — this was causing CJS require() to be injected into ESM (.mjs) files
  • Removes tracePromise assertions from transformation tests (implementation detail of the old WASM output; the new JS transformer uses runStores instead)
  • Bumps dc-browser to v1.0.4, which adds a default export to match Node.js CJS-ESM interop behaviour required by the diagnostics_channel-based wrappers

Test plan

  • All unit tests pass (pnpm test in js/)
  • Transformation tests pass (esbuild, vite, webpack, rollup bundlers)
  • Loader hook integration tests pass (ESM + CJS)
  • End-to-end tests pass (Anthropic, OpenAI with mock fetch)

🤖 Generated with Claude Code

@socket-security
Copy link
Copy Markdown

socket-security bot commented Mar 31, 2026

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@Qard Stephen Belanger (Qard) force-pushed the upgrade-orchestrion-0.11 branch 4 times, most recently from 6678db1 to 3d5c151 Compare April 2, 2026 20:14
Stephen Belanger (Qard) and others added 5 commits April 4, 2026 18:47
…r v0.11.0 JS rewrite

- Bump version range to >=0.9.0 to pick up v0.11.0 when released
- Fix ESM loader hook to pass correct module type (esm/cjs/unknown) from
  Node.js loader format instead of always passing "unknown", which caused
  CJS require() to be injected into ESM files
- Remove tracePromise assertions from transformation tests (implementation
  detail of old WASM output; new JS version uses runStores instead)
- Clean up "WASM transformer" wording in comments

Tested against nodejs/orchestrion-js main branch. The browser-mode tests
(dc-browser) require apm-js-collab/dc-browser#3 to be merged and released
first, since dc-browser was missing a default export to match
node:diagnostics_channel's CJS-ESM interop behaviour.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
v1.0.4 adds a default export to match Node.js CJS-ESM interop
behaviour, which is required for the diagnostics_channel-based
wrappers to work correctly in mixed ESM/CJS projects.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dc-browser is an internal package we control. Publishing new versions
should not cause CI to fail for 3 days due to the release age check.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dc-browser is an internal package we control — the release age guard is
meant for third-party supply-chain protection, not our own packages.
The exclude belongs in pnpm-workspace.yaml where the constraint lives.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…esponse() for v0.11.0

Two e2e failures in the upgrade-orchestrion-0.11 PR:

1. AI SDK CJS streamText/streamObject: The PR changed kind "Sync" to "Async"
   for CJS bundles, but with v0.11.0 wrapPromise, asyncEnd never fires for
   non-thenable results (DefaultStreamTextResult has no .then). Revert to
   kind "Sync" + traceSyncStreamChannel which fires end.publish() and is
   handled correctly by the end handler via the bindStore-created span state.

2. Anthropic .withResponse(): v0.11.0 wrapPromise returns promise.then(cb)
   (a plain Promise) instead of the original APIPromise, making .withResponse()
   unavailable and crashing the auto-instrumentation e2e scenario. Guard the
   call with a supportsWithResponse option set to false for auto-instrumented
   paths. Span capture is unaffected since asyncEnd still fires correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The stream-with-response-operation was calling client.messages.stream()
unconditionally, but under auto-instrumentation with orchestrion v0.11.0
the transformer wraps the return value of messages.create() as a plain
Promise, which makes messages.stream() fail internally when it tries to
call .withResponse() on it.

Restore the guard that uses messages.create({stream:true}) instead when
useMessagesStreamHelper is false (the auto-hook path).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants